"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const mocha_1 = require("mocha");
const dayjs_1 = __importDefault(require("dayjs"));
const binance_api_1 = require("./binance-api");
const config = require('../../etc/config');
mocha_1.describe('币安Api测试', () => {
    const { host } = config;
    const binance = new binance_api_1.MarkApi(host, '/api/v3');
    mocha_1.it(`price`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.price();
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`priceParam`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.priceParam('ETHBTC');
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`priceParams`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.priceParams(['ETHUSDT', 'BTCUSDT', 'ETHBTCx']);
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`exChangeInfo`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.exChangeInfo();
        console.log(res);
    }));
    mocha_1.it(`exChangeInfoParam`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.exChangeInfoParam('ETHBTC');
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`exChangeInfoParams`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.exChangeInfoParams(['ETHBTC', 'BTCUSDT', 'ETHUSDT']);
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`depth`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.depth({ symbol: 'ETHBTC' });
        const resLimit = yield binance.depth({ symbol: 'ETHBTC', limit: 1000 });
        console.log(JSON.stringify(res));
        console.log(JSON.stringify(resLimit));
    }));
    mocha_1.it(`trades`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.trades({ symbol: 'ETHBTC' });
        const resLimit = yield binance.trades({ symbol: 'ETHBTC', limit: 1000 });
        console.log(JSON.stringify(res));
        console.log(JSON.stringify(resLimit));
    }));
    mocha_1.it(`aggTrades`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.aggTrades({ symbol: 'ETHBTC' });
        const resLimit = yield binance.aggTrades({ symbol: 'ETHBTC', limit: 1000 });
        console.log(JSON.stringify(res));
        console.log(JSON.stringify(resLimit));
    }));
    mocha_1.it(`aggTradesByTime`, () => __awaiter(void 0, void 0, void 0, function* () {
        const endTime = dayjs_1.default().valueOf();
        const startTime = dayjs_1.default().subtract(1, 'minute').valueOf();
        const res = yield binance.aggTradesByTime({ symbol: 'ETHBTC', startTime: startTime, endTime: endTime });
        const resLimit = yield binance.aggTradesByTime({ symbol: 'ETHBTC', startTime: startTime, endTime: endTime, limit: 1000 });
        console.log(JSON.stringify(res));
        console.log(JSON.stringify(resLimit));
    }));
    mocha_1.it(`avgPriceParam`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.avgPriceParam('ETHBTC');
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`tickerDaily`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.tickerDaily();
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`tickerDailyParam`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.tickerDailyParam(`ETHBTC`);
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`tickerDailyParams`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.tickerDailyParams(['ETHBTC', 'BTCUSDT']);
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`bookTicker`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.bookTicker();
        console.log(res[0].symbol);
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`bookTickerParam`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.bookTickerParam('ETHBTC');
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`bookTickerParams`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.bookTickerParams(['ETHBTC', 'BTCUSDT']);
        console.log(JSON.stringify(res));
    }));
    mocha_1.it(`klines`, () => __awaiter(void 0, void 0, void 0, function* () {
        const res = yield binance.klines({ symbol: 'ETHBTC', interval: '1m' });
        const resLimit = yield binance.klines({ symbol: 'ETHBTC', interval: '1m', limit: 1000 });
        console.log(JSON.stringify(res));
        console.log(JSON.stringify(resLimit));
    }));
    mocha_1.it(`klinesByTime`, () => __awaiter(void 0, void 0, void 0, function* () {
        const endTime = dayjs_1.default().valueOf();
        const startTime = dayjs_1.default().subtract(3, 'minute').valueOf();
        const res = yield binance.klinesByTime({ symbol: 'ETHBTC', interval: '1m', startTime: startTime, endTime: endTime });
        // const resLimit = await binance.klinesByTime({ symbol: 'ETHBTC', interval: '1m', startTime: startTime, endTime: endTime, limit: 1000 })
        // console.log(JSON.stringify(res[0]))
        // console.log(res.length)
        // console.log(JSON.stringify(resLimit))
    }));
    mocha_1.it(`klinesTime`, () => __awaiter(void 0, void 0, void 0, function* () {
        const endTime = dayjs_1.default().valueOf();
        const startTime = dayjs_1.default().subtract(3 * 1000, 'd').valueOf();
        console.log(startTime);
        const res = yield binance.kinesTime({ symbol: 'ETHBTC', interval: '3d', startTime: startTime, endTime: endTime, limit: 1000 });
        console.log(JSON.stringify(res));
    }));
});
